package com.susallwave.srcb.response;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {
    private int code;
    private String message;
    private T data;

    // ========== 成功响应 ==========
    public static <T> Result<T> success() {
        return new Result<>(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMsg(), null);
    }

    public static <T> Result<T> success(T data) {
        return new Result<>(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMsg(), data);
    }

    // ========== 错误响应 ==========
    public static <T> Result<T> error(String message) {
        return new Result<>(ResultEnum.ERROR.getCode(), message, null);
    }

    // 使用枚举定义的状态码
    public static <T> Result<T> error(ResultEnum ResultEnum) {
        return new Result<>(ResultEnum.getCode(), ResultEnum.getMsg(), null);
    }
}

